package com.ctgu.springboot.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ctgu.springboot.common.QueryPageParam;
import com.ctgu.springboot.common.Result;
import com.ctgu.springboot.entity.Team;
import com.ctgu.springboot.entity.Teamlog;
import com.ctgu.springboot.entity.TraInfo;
import com.ctgu.springboot.service.TeamService;
import com.ctgu.springboot.service.TeamlogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author cs
 * @since 2023-07-07
 */
@RestController
@RequestMapping("/teamlog")
public class TeamlogController {
    @Autowired
    private TeamlogService teamlogService;
    //显示团队日志列表
    @RequestMapping("list")
    public List<Teamlog> list(){
        return teamlogService.list();
    }

    //新增团队日志
    @PostMapping("/save")
    public Result save(@RequestBody Teamlog teamlog){
        return teamlogService.save(teamlog) ? Result.suc() :Result.fail();
    }

    //更新团队日志信息
    @PostMapping("/update")
    public Result update(@RequestBody Teamlog teamlog){
        return teamlogService.updateById(teamlog) ? Result.suc() : Result.fail();
    }

    //删除团队日志（根据ID）
    @GetMapping("/del")
    public Result del(@RequestParam String teamlog_id){
        return teamlogService.removeById(teamlog_id) ? Result.suc() : Result.fail();
    }

    //分页查询团队日志信息
    @PostMapping("/listPage")
    public Result listPage(@RequestBody QueryPageParam query){
        IPage<Teamlog> result = teamlogService.teamlogPage(query);
        return Result.suc(result.getRecords(),result.getTotal());
    }
    //获取所有团队日志信息
    @GetMapping("getList")
    public List<Teamlog> getList(){
        return teamlogService.getList();
    }
}
